

data1 <- data_for_p %>%
    rename(Score = riskscore) %>%
    group_by(riskgroup, Response) %>%
    summarise(n = n()) %>%
    mutate(Percent = n/sum(n) * 100) %>%
    mutate(txt = str_c(sprintf("%.2f", Percent)))

p_percent <- ggplot(data = data1, aes(Score, Percent, fill = Response_infor)) +
    geom_col(width = 0.6) +
    geom_text(aes(label = txt),
        position = position_stack(vjust = 0.5), size = 5,
        color = "white"
    ) +
    scale_fill_manual(values = c("#F09D1A", "#984EA3")) +
    annotate("text", label = p.value, color = "black", y = 104, x = 1.15, size = 3) +
    theme_test(13) +
    theme(legend.position = "top") + # guides(fill = guide_legend(nrow = 2))+ theme_test(13)
    labs(x = "", fill = "", y = "Percent(%)") +
    scale_x_discrete(labels = c(
        "High Score",
        "Low Score"
    )) +
    theme(axis.text.x.bottom = element_text(size = 11))
